package cn.enilu.flash.enums.body;

import cn.enilu.flash.enums.OptionObject;

import java.util.HashMap;
import java.util.Map;

public enum BuildingType  implements OptionObject {

    BUSINESS(1, "商用"),
    HOME(2, "普通民宅"),
    BOTH(3, "商住两用"),
    BOTTOM(4, "底商"),
    LOFT(5, "公寓"),
    OTHER(9, "其他")
    ;

    private int code;
    private String text;


    BuildingType(int code, String text){
        this.code = code;
        this.text = text;
    }

    public static Map<Integer, String> toMap = new HashMap<Integer, String>();

    static {
        BuildingType[] types = BuildingType.values();
        for (BuildingType type : types) {
            toMap.put(type.getCode(), type.getText());
        }
    }

    public static String valueOfCode(int code) {
        BuildingType[] bts = BuildingType.values();
        for (BuildingType bt : bts) {
            if(bt.getCode() == code){
                return bt.getText();
            }
        }
        return "--";
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getText() {
        return this.text;
    }

    @Override
    public boolean compare(int code){
        if(this.getCode() == code){
            return true;
        }
        return false;
    }


}
